package com.knight.study.patterns.tujie.prototype;

/**
 * @Author knight
 * @Date 2024/9/10 16:12
 */

public class MessageBox implements Product{
    private char decochar;

    public MessageBox(char decochar) {
        this.decochar = decochar;
    }

    public char getDecochar() {
        return decochar;
    }

    public void setDecochar(char decochar) {
        this.decochar = decochar;
    }

    @Override
    public void use(String s) {
        final int length = s.getBytes().length;
        for (int i = 0; i < length + 4; i++) {
            System.out.println(decochar);
        }
        System.out.println("");
        System.out.println(decochar + " " + s + " " + decochar);
        for (int i = 0; i < length + 4; i++){
            System.out.print(decochar);
        }
        System.out.println("");
    }

    @Override
    public Product createClone() {
        Product p = null;
        try {
            p = (Product)clone();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return p;
    }
}
